/**
 * Created by Galois on 2017/7/5.
 */
/**
 * Created by Galois on 2017/7/4.
 */
$(function(){
    console.log("加油");
    var mainLoading = false;
    getContent();

    function getData(result) {
        if(result.status==200){
            return result.data;
        }else{
            alert(result.messages||"获取信息错误");
            return null;
        }
    }

    function getContent(result){
        if (mainLoading) return;
        console.log("getContent");
        $.get("Article/index.action",function (result, err) {
            var items = getData(result);
            appendContent(items);
        })

        mainLoading = true;
    }

    /*把获取到的列表信息填充入#List中*/
    function appendContent(items){
        console.log("appendContent");
        var contentMain;
        var listContentMain=[];
        items.forEach(function(itemMain){
            listContentMain.push('<div class="main" id="main">');
            listContentMain.push('    <div class="main_content">');
            listContentMain.push('        <div class="news">');
            listContentMain.push('            <div class="news_title">');
            listContentMain.push('                <h>'+ itemMain.title[0] +'</h>');
            listContentMain.push('                <a href="'+ itemMain.moreHref[0] +'">更多<img src="images/more_too.jpg"></a>');
            listContentMain.push('           </div>');
            listContentMain.push('            <div class="news_content">');
            listContentMain.push('                <ul>');
            listContentMain.push('                    <li><i class="blog"></i><a target="_blank" href="'+ itemMain.aboutMeHref[0] +'">'+ itemMain.aboutMe[0] +'</a></li>');
            listContentMain.push('                    <li><i class="blog"></i><a target="_blank" href="'+ itemMain.aboutMeHref[1] +'">'+ itemMain.aboutMe[1] +'</a></li>');
            listContentMain.push('                    <li><i class="blog"></i><a target="_blank" href="'+ itemMain.aboutMeHref[2] +'">'+ itemMain.aboutMe[2] +'</a></li>');
            listContentMain.push('                    <li><i class="blog"></i><a target="_blank" href="'+ itemMain.aboutMeHref[3] +'">'+ itemMain.aboutMe[3] +'</a></li>');
            listContentMain.push('                    <li><i class="blog"></i><a target="_blank" href="'+ itemMain.aboutMeHref[4] +'">'+ itemMain.aboutMe[4] +'</a></li>');
            listContentMain.push('                    <li><i class="blog"></i><a target="_blank" href="'+ itemMain.aboutMeHref[5] +'">'+ itemMain.aboutMe[5] +'</a></li>');
            listContentMain.push('                </ul>');
            listContentMain.push('            </div><!--news_content结束-->');
            listContentMain.push('        </div><!--news结束-->');

            listContentMain.push('        <div class="news2">');
            listContentMain.push('            <div class="news_title">');
            listContentMain.push('                <h>'+ itemMain.title[1] +'</h>');
            listContentMain.push('                <a href="'+ itemMain.moreHref[1] +'">更多<img src="images/more_too.jpg"></a>');
            listContentMain.push('            </div><!--news_title结束-->');
            listContentMain.push('            <div class="news_content">');
            listContentMain.push('                <ul>');
            listContentMain.push('                    <li><i class="asdf"></i><a target="_blank" href="'+ itemMain.aboutMeHref[6] +'">'+ itemMain.aboutMe[6] +'</a></li>');
            listContentMain.push('                    <li><i class="asdf"></i><a target="_blank" href="'+ itemMain.aboutMeHref[7] +'">'+ itemMain.aboutMe[7] +'</a></li>');
            listContentMain.push('                    <li><i class="asdf"></i><a target="_blank" href="'+ itemMain.aboutMeHref[8] +'">'+ itemMain.aboutMe[8] +'</a></li>');
            listContentMain.push('                    <li><i class="asdf"></i><a target="_blank" href="'+ itemMain.aboutMeHref[9] +'">'+ itemMain.aboutMe[9] +'</a></li>');
            listContentMain.push('                    <li><i class="asdf"></i><a target="_blank" href="'+ itemMain.aboutMeHref[10] +'">'+ itemMain.aboutMe[10] +'</a></li>');
            listContentMain.push('                    <li><i class="asdf"></i><a target="_blank" href="'+ itemMain.aboutMeHref[11] +'">'+ itemMain.aboutMe[11] +'</a></li>');
            listContentMain.push('                </ul>');
            listContentMain.push('            </div><!--news_content结束-->');
            listContentMain.push('        </div><!--news2结束-->');

            listContentMain.push('        <div class="news3">');
            listContentMain.push('            <div class="news_title">');
            listContentMain.push('                <h>'+ itemMain.title[2] +'</h>');
            listContentMain.push('                <a href="'+ itemMain.moreHref[2] +'">更多<img src="images/more_too.jpg"></a>');
            listContentMain.push('            </div><!--news_title结束-->');
            listContentMain.push('            <div class="news_content">');
            listContentMain.push('                <ul>');
            listContentMain.push('                    <li><i class="asdf"></i><a target="_blank" href="'+ itemMain.aboutMeHref[12] +'">'+ itemMain.aboutMe[12] +'</a></li>');
            listContentMain.push('                    <li><i class="asdf"></i><a target="_blank" href="'+ itemMain.aboutMeHref[13] +'">'+ itemMain.aboutMe[13] +'</a></li>');
            listContentMain.push('                    <li><i class="asdf"></i><a target="_blank" href="'+ itemMain.aboutMeHref[14] +'">'+ itemMain.aboutMe[14] +'</a></li>');
            listContentMain.push('                    <li><i class="asdf"></i><a target="_blank" href="'+ itemMain.aboutMeHref[15] +'">'+ itemMain.aboutMe[15] +'</a></li>');
            listContentMain.push('                    <li><i class="asdf"></i><a target="_blank" href="'+ itemMain.aboutMeHref[16] +'">'+ itemMain.aboutMe[16] +'</a></li>');
            listContentMain.push('                    <li><i class="asdf"></i><a target="_blank" href="'+ itemMain.aboutMeHref[17] +'">'+ itemMain.aboutMe[17] +'</a></li>');
            listContentMain.push('                </ul>');
            listContentMain.push('            </div><!--news_content结束-->');
            listContentMain.push('        </div><!--news3结束-->');
            listContentMain.push('    </div><!--main_content结束-->');
            listContentMain.push('</div><!--main结束-->');
        });
        contentMain = listContentMain.join("");                 //  连成一句话
        $("#contentMain").append(contentMain);
        mainLoading = false;     //加载完毕
    }
});

